<?php
require $_SERVER['DOCUMENT_ROOT'].'/../_core/common.php';

//权限验证
if( Role::init() == false ){
	exit('没有权限');
}

require $_SERVER['DOCUMENT_ROOT'].'/../_interface/pages.php';
require $_SERVER['DOCUMENT_ROOT'].'/../_interface/name.php';

$db = new DB();

$page = isset($_GET['page']) ? intval($_GET['page']) : 1;//当前页码
$pageSize = 20;//每页条数

//查询总记录数
$total_sql = 'select id from logs_articles';
$total = $db->query($total_sql)->getCount();

//分页html
$page_html = Pages::page($page, $total, $pageSize, '/admin/log/online_action.php');

//查询当前页记录
$online_action_sql = 'select uid,category_id,status,title_id,title,created from logs_articles order by created desc limit '.(($page-1)*$pageSize).','.$pageSize;
$online_action_rs = $db->query($online_action_sql)->getAll();

$db = new DB('news');
$action_arr = array(1=>'进入列表页', 2=>'进入添加页', 3=>'进入编辑页', 4=>'删除', 5=>'恢复', 6=>'批量排序', 7=>'批量删除', 8=>'彻底删除', 9=>'批量移动', 10=>'立即发布', 11=>'置顶', 12=>'编辑整页', 13=>'取消置顶', 14=>'添加', 15=>'编辑');
foreach( $online_action_rs as $key=>$val ){
	//查询姓名
	$username = Name::get_username($db, $val['uid']);
	$online_action_rs[$key]['username'] = $username;
	
	//查询栏目名称
	$category_name = Name::get_catename($db, $val['category_id']);
	$online_action_rs[$key]['category_name'] = $category_name;
	
	//查询操作名字
	$action_name = $action_arr[ $val['status'] ];
	$online_action_rs[$key]['action_name'] = $action_name;
}

require template('admin/log/online_action');